<?php
include dirname( __FILE__ ).'/alipaypage/pagepay/service/AlipayTradeService.php';
include dirname(__FILE__).'/alipaypage/pagepay/buildermodel/AlipayTradePagePayContentBuilder.php';

class Pagepay{
	
	
	var $alipay_config;
	var $data;
	function __construct($alipay_config,$data){
		$this->alipay_config = $alipay_config;
		$this->data = $data;
	}
	
	public function buildRequestPara() {
		//构造参数

		$payRequestBuilder = new AlipayTradePagePayContentBuilder();

		$payRequestBuilder->setBody($this->data['body']);

		$payRequestBuilder->setSubject($this->data['subject']);

		$payRequestBuilder->setTotalAmount($this->data['total_amount']);

		$payRequestBuilder->setOutTradeNo($this->data['out_trade_no']);
		
		$config = $this->alipay_config;
		$aop = new AlipayTradeService($config);
		
		$response = $aop->pagePay($payRequestBuilder,$config['return_url'],$config['notify_url']);
		
		return true;
	}
	
}
?>
